<html>
<head>
<title>Page d'ajout Dentiste</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="<?php echo base_url();?>css/stylesheet.css" />
<script type="text/javascript" src="<?php echo base_url(); ?>js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>js/control.js"></script>
<script src="<?php echo base_url(); ?>js/jquery.form.js"></script>
<script>
$(document).ready( function () {
	var $form = $('#formulaire1');
	var $result = $('#ajaxPhotodentisteAff');
	$form.delegate('#photo_dentiste', 'change', function(){
		var $url = "<?php echo base_url();?>upload/photodentiste/";
		var $url1 = $url.replace("C:\\fakepath\\", ""); 
		$form.ajaxForm({
			target: $result,
			success:function(data){ 
				var $logo1 = data;
				var $logo1aff = $logo1.replace("C:\\fakepath\\", ""); 
				$('#photo_dentiste_hidden').val(data);
				console.log('form');
 				$("#ajaxPhotodentisteAff").html("<img src='"+$url1+$logo1aff+"' height='50px;' width='70px;' />");				
			}
		}).submit();
	});
	$("#go").click(function(){
		var photo_dentiste = $("#photo_dentiste").val();
		var id_dentiste = $("#id_dentiste").val();
		var id_clinique = $("#id_clinique").val();
		var nom_dentiste = $("#nom_dentiste").val();
		var fonction_dentiste = $("#fonction_dentiste").val();
		var annee_exp1 = $("#annee_exp1").val();
		var annee_exp2 = $("#annee_exp2").val();
		var annee_exp3 = $("#annee_exp3").val();
		var annee_exp4 = $("#annee_exp4").val();
		var annee_exp5 = $("#annee_exp5").val();
		var annee_exp6 = $("#annee_exp6").val();
		var exp1 = $("#exp1").val();
		var exp2 = $("#exp2").val();
		var exp3 = $("#exp3").val();
		var exp4 = $("#exp4").val();
		var exp5 = $("#exp5").val();
		var exp6 = $("#exp6").val();
		var langue1 = $("#langue1").val();
		var langue2 = $("#langue2").val();
		var langue3 = $("#langue3").val();
		if (id_clinique != ""){
			$.post("<?php echo base_url();?>index.php/admin/updateEquipeClinique", {photo_dentiste:photo_dentiste, id_dentiste:id_dentiste, id_clinique:id_clinique, nom_dentiste:nom_dentiste, fonction_dentiste:fonction_dentiste, annee_exp1:annee_exp1, annee_exp2:annee_exp2, annee_exp3:annee_exp3, annee_exp4:annee_exp4, annee_exp5:annee_exp5, annee_exp6:annee_exp6, exp1:exp1, exp2:exp2, exp3:exp3, exp4:exp4, exp5:exp5, exp6:exp6, langue1:langue1, langue2:langue2, langue3:langue3},				
					function(data){
						var urlredirect = "<?php echo base_url(); ?>index.php/admin/infoEquipe?id="+id_clinique;
						document.location = urlredirect;
					}
				);
			
		}
	});
	$("#fermer").click(function(){
		var id_clinique = $("#id_clinique").val();
		var urlredirect = "<?php echo base_url(); ?>index.php/admin/infoEquipe?id="+id_clinique;
		document.location = urlredirect;
	});
});
</script>
</head>
<body>
<div class="wrap" style="width:736px;">
<div class="right2" style="width:100%">	
	<!--<h2>Notre Equipe</h2>-->
	<?php
		$id_clinique="";
		if ($result!=0){
 		foreach ($result as $key => $list){	
		?>
		<div class="box marged">
		<table>
			<input type="hidden" value="<?php echo $list['id_dentiste'] ?>" id="id_dentiste" name="id_dentiste"/>
			<input type="hidden" value="<?php echo $list['id_clinique'] ?>" id="id_clinique" name="id_clinique"/>
				<tr>
					<td>Image</td>
					<td>
						<?php echo form_open_multipart('admin/uploadimage?sary=photo_dentiste',' id="formulaire1"'); ?>
							<input name="photo_dentiste" type="file"  id="photo_dentiste"  value="<?php echo base_url();?>upload/photodentiste/<?php echo $list['photo_dentiste'] ?>" class="obligatoire"/>
							<div id="ajaxPhotodentisteAff">
								<img src="<?php echo base_url();?>upload/photodentiste/<?php echo $list['photo_dentiste'] ?>" height="50px;" width="70px;"/>
								<input type="hidden" value="<?php echo $list['photo_dentiste'];?>" id="photo_dentiste_hidden" />
							</div>
						</form>
					</td>
				</tr>
				<tr>
					<td>Nom</td>
					<td><input name="nom_dentiste" type="text"  id="nom_dentiste"  value="<?php echo $list['nom_dentiste'] ?>" class="obligatoire"/></td>
				</tr>
				<tr>
					<td>Fonction</td>
					<td><input name="fonction_dentiste" type="text"  id="fonction_dentiste"  value="<?php echo $list['fonction_dentiste'] ?>" class="obligatoire"/></td>
				</tr> 
				<tr>
					<td colspan="2">Experiences professionnelles</td>
				</tr>
				<?php
				for($i = 1; $i <= 6; $i++){
					if($list['annee_exp'.$i] != "" && $list['exp'.$i] != ""){
				?>
				<tr>
					<td></td>
					<td>
						Date : <input name="annee_exp<?php echo $i; ?>" type="text"  id="annee_exp<?php echo $i; ?>"  value="<?php echo $list['annee_exp'.$i] ?>" class="obligatoire"/>
				    	Experience : <input name="exp<?php echo $i; ?>" type="text"  id="exp<?php echo $i; ?>"  value="<?php echo $list['exp'.$i] ?>" class="obligatoire"/>
				    </td>
				</tr>
				<?php	
					}
				}
				?>
				<tr>
					<td colspan="2">Langue parl&eacute;e  </td>
				</tr>
				<?php
				for($i = 1; $i <= 3; $i++){
					if($list['langue'.$i] != ""){
				?>
				<tr>
					<td></td>
					<td>
						<select name="langue<?php echo $i; ?>" id="langue<?php echo $i; ?>">
							<option value = "" <?php if($list['langue'.$i]==""){ echo ' selected="selected"';} ?> >S&eacute;lectionner</option>
							<option value="francais" <?php if($list['langue'.$i]=="francais"){ echo ' selected="selected"';} ?>>francais</option>
							<option value="anglais" <?php if($list['langue'.$i]=="anglais"){ echo ' selected="selected"';} ?>>anglais</option>
							<option value="allemand" <?php if($list['langue'.$i]=="allemand"){ echo ' selected="selected"';} ?>>allemand</option>
							<option value="hongrois" <?php if($list['langue'.$i]=="hongrois"){ echo ' selected="selected"';} ?>>hongrois</option>
						</select>
					</td>
				</tr>
				<?php	
					}
				}
				?>	
				<tr>
					<td colspan="2"></td>
				</tr>
				<tr>
					<td colspan="2"></td>
				</tr>	
				<tr>
					<td colspan="2"></td>
				</tr>				
				<tr>
					<td></td>
					<td><input type="submit" name="submit" id="go" value="Enregistrer modifications" />
						<input type="button" name="button" id="fermer" value="Annuler" />
					</td>
				</tr>
		</table>
		</div>
		<?php
		}
	}
	?>	
</div>
</div>
</body>
</html>